import logging
from datetime import timedelta

from redis import Redis




class Config:
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/monkeydb"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    REDIS_HSOT = "127.0.0.1"
    REDIS_PORT = 6379
    SESSION_TYPE = "redis"  # 设置redis的储存类型
    SESSION_REDIS = Redis(host=REDIS_HSOT, port=REDIS_PORT)
    SESSION_USE_SIGNER = True
    SECRET_KEY = "xcvhlkjxvhdsfuoiernvxncmvidsfan"
    PERMANENT_SESSION_LIFETIME = timedelta(days=7)  # 设置session的过期时间

# 开发环境
class DevelepConfig(Config):
    DEBUG = True
    LOG_LEVEL = logging.DEBUG



# 生产环境
class productConfig(Config):
    DEBUG = False
    LOG_LEVEL = logging.ERROR


config_dict = {
    "pro": productConfig,
    "dev": DevelepConfig
}
